package messaging;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;

public class RebalanceUpdates implements Serializable
{
  /**
   * Array List of nodes in the new predecessor/successor set.
   */
  private ArrayList<Integer> newnodeset;
  /**
   * A hashmap of hash data of all newly added nodes to be sent to the predecessor for 
   * fault tolerance.
   * Also a hashmap of hash data of all nodes received from its successor for fault tolerance.
   */
  private HashMap<Integer, HashMap<String, Serializable>> datafaulttolerace = 
      new HashMap<Integer,HashMap<String, Serializable>>();
  /**
   * a boolean indicating whether the sender of the message is a predecessor or a 
   * successor to the node being sent.
   * true - sender is predecessor to the sent node.
   * false - sender is successor to the sent node.
   */
  private boolean predsuccid;
  /**
   * Constructor.
   */
  public RebalanceUpdates()
  {
    super();
  }
  /**
   * setter for newnodeset.
   */
  public void setnewnodesets(ArrayList<Integer> newnodeset)
  {
    this.newnodeset = newnodeset;
  }
  /**
   * getter for newnodeset.
   */
  public ArrayList<Integer> getnewnodeset()
  {
    return this.newnodeset;
  }
  /**
   * setter for data for fault tolerance.
   */
  public void setStorageData(HashMap<Integer,HashMap<String, Serializable>> datatostore)
  {
    this.datafaulttolerace = datatostore;
  }
  /**
   * Getter for storage data.
   */
  public HashMap<Integer,HashMap<String, Serializable>> getStorageData()
  {
    return this.datafaulttolerace;
  }
  /**
   * set the boolean
   */
  public void setpredsuccid(boolean id)
  {
    this.predsuccid = id;
  }
  /**
   * gets the pred succ id.
   */
  public boolean getId()
  {
    return this.predsuccid;
  }
}
